package be.djdb.manipulators.streams.util;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import be.djdb.manipulators.streams.StreamPieceUtilConverter;

/**
* @author Lieven Roegiers
* @copyright 2009
* @from UpdateCV
*/
public class StreampieceStringreplacer implements StreamPieceUtilConverter{
	String replacement;
	public StreampieceStringreplacer(String replacement) {
		this.replacement =  replacement;
	}
	@Override
	public void replace(char[] toreplace, OutputStreamWriter out)throws Exception {
			replace(new String(toreplace),out);
	}
	@Override
	public void replace(String toreplace, OutputStreamWriter out)throws IOException{
		String replacer=(replacement.isEmpty())?"null":this.replacement;
		out.append(replacer);
	}
}
